package com.demo.auth.config;

import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;

/**
 * token 的信息配置类 存储 redis
 *
 * @author YT
 * @date 2019-07-09
 */
@Configuration
@AllArgsConstructor
public class TokenStoreConfig {

    /**
     * redis 连接工厂
     */
    private final RedisConnectionFactory redisConnectionFactory;

    /**
     * 用于存储 token
     * @return
     */
    @Bean
    public TokenStore tokenStore(){
        return new RedisTokenStore(redisConnectionFactory);
    }
}
